package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	SellerLevelEventNew           = "erp.SellerLevelNew"
	SellerLevelEventBeforeCreate  = "erp.SellerLevelBeforeCreate"
	SellerLevelEventBeforeUpdate  = "erp.SellerLevelBeforeUpdate"
	SellerLevelEventBeforeSave    = "erp.SellerLevelBeforeCreate erp.SellerLevelBeforeUpdate"
	SellerLevelEventAfterCreate   = "erp.SellerLevelAfterCreate"
	SellerLevelEventAfterUpdate   = "erp.SellerLevelAfterUpdate"
	SellerLevelEventAfterSave     = "erp.SellerLevelAfterCreate erp.SellerLevelAfterUpdate"
	SellerLevelEventDelete        = "erp.SellerLevelDelete"
	SellerLevelAccessControlEvent = "erp.SellerLevelAccessControl"
)

func GetSellerLevelConfig() *mgo.DocConfig {
	return SellerLevel_Config
}

var SellerLevel_Config *mgo.DocConfig

func init() {
	SellerLevel_Config = NewSellerLevelConfig()
}
func NewSellerLevelConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "erp.SellerLevel",
		Fields: []string{
			"name", "sort", "l", "r", "level", "link", "parent", "children",
		},
		RelationFields: []string{
			"parent", "children",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"parent": {
				Config:     GetSellerLevelConfig,
				DocName:    "SellerLevel",
				JoinType:   "O",
				KeyInside:  "parentId",
				KeyOutSide: "id",
			},
			"children": {
				Config:     GetSellerLevelConfig,
				DocName:    "SellerLevel",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "parentId",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
